/**
 *Class message
 *
 * version 1.0
 *
 * @author Jin Kit Chua
 * @version 20130319 V1.0
 */
package ch.zbw.iCoach.kit;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class Message {

	private JFrame mainFrame;

	private JButton close;

	private JLabel msg;

	/**
	 * 
	 * @param actualMsg message everyone can send to use for test
	 */
	public Message(String actualMsg) {

		this.mainFrame = new JFrame("Message");

		this.close = new JButton("close");

		this.msg = new JLabel("     " + actualMsg);

		paint();
	}

	public void paint() {

		this.mainFrame.setBackground(Color.lightGray);
		this.mainFrame.setResizable(false);

		mainFrame.setLayout(new BorderLayout(10, 20));

		this.mainFrame.add(this.close, BorderLayout.SOUTH);
		this.mainFrame.add(this.msg, BorderLayout.CENTER);

		this.mainFrame.setSize(400, 250);
		this.mainFrame.setVisible(true);
		this.mainFrame.setLocation(650, 400);

		this.close.addActionListener(new ActionListenerClose());
	}

	class ActionListenerClose implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			mainFrame.dispose();
		}
	}
}
